1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30 package org.universAAL.lddi.manager.publisher;
31
32
33 import java.awt.event.WindowAdapter;
34 import java.awt.event.WindowEvent;
35
36 import javax.swing.JDialog;
37
38 import org.osgi.framework.Bundle;
39 import org.osgi.framework.BundleActivator;
40 import org.osgi.framework.BundleContext;
41 import org.osgi.framework.BundleException;
42 import org.universAAL.lddi.manager.gui.GUI;
43 import org.universAAL.middleware.container.ModuleContext;
44 import org.universAAL.middleware.container.osgi.uAALBundleContainer;
45
46
47
48
49 public class Activator implements BundleActivator {
50
51
52
53
54
55 private GUI gui = null;
56
57
58
59
60 private ModuleContext mdlContext;
61 private BundleContext bndContext;
62 private ServiceProvider service;
63 public static boolean dllReadyLatch = true;
64
65
66
67 public void start(BundleContext context) throws Exception {
68 mdlContext = uAALBundleContainer.THE_CONTAINER
69 .registerModule(new Object[] { context });
70
71 bndContext = context;
72 gui = new GUI(bndContext);
73 gui.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
74 gui.addWindowListener(new WindowAdapter() {
75 public void windowClosing(WindowEvent e) {
76 gui.setVisible(false);
77 }
78 });
79
80 gui.setVisible(false);
81
82 service = new ServiceProvider(mdlContext,gui);
83 }
84
85
86 public void stop(BundleContext arg0) throws Exception {
87 gui.setVisible(false);
88 dllReadyLatch = true;
89
90
91
92 }
93
94 void stopSafe(final Bundle bundle) {
95 new Thread() {
96 public void run() {
97 try {
98 bundle.stop();
99 } catch (BundleException e) {
100
101 e.printStackTrace();
102 }
103 }
104 }.start();
105 }
106
107 }